import Layout from '@/layout/index.vue';

const devTestRoutes = [
    {
        path: '/test',
        name: 'test',
        meta: {
            hideMenu: true
        },
        children: [
            {
                path: 'a',
                component: () => import('@/pages/test/a.vue')
            },
            {
                path: 'b',
                component: () => import('@/pages/test/b.vue')
            },
            {
                path: 'setter',
                component: () => import('@/pages/test/setter.vue')
            },
            {
                path: 'render',
                component: () => import('@/pages/test/render.vue')
            },
            {
                path: 'builder',
                component: () => import('@/pages/test/builder.vue')
            }
        ]
    }
];

export default [
    {
        path: '/',
        name: 'layout',
        component: Layout,
        redirect: '/dashboard',
        children: [
            {
                path: '/dashboard',
                name: 'dashboard',
                component: () => import('@/pages/index.vue'),
                meta: {
                    title: '工作台',
                    keepAlive: true,
                    permission: 'page:dashboard:index'
                }
            },
            {
                path: '/model',
                name: 'model',
                meta: {
                    title: '数据建模'
                },
                redirect: '/model/thing',
                children: [
                    {
                        path: '/model/thing',
                        name: 'model-thing',
                        meta: {
                            title: '物模型定义'
                        },
                        redirect: '/model/thing/list',
                        children: [
                            {
                                path: 'list',
                                name: 'model-thing-list',
                                component: () => import('@/pages/model/thing/list.vue'),
                                meta: {
                                    keepAlive: true,
                                    hideMenu: true,
                                    permission: 'model:thing:list'
                                }
                            },
                            {
                                path: 'detail/:id',
                                name: 'model-thing-detail',
                                component: () => import('@/pages/model/thing/detail.vue'),
                                meta: {
                                    title: '查看模型',
                                    keepAlive: true,
                                    hideMenu: true,
                                    permission: 'model:thing:detail'
                                }
                            }
                        ]
                    },
                    {
                        path: '/model/business',
                        name: 'model-business',
                        meta: {
                            title: '业务模型定义'
                        },
                        redirect: '/model/business/list',
                        children: [
                            {
                                path: 'list',
                                name: 'model-business-list',
                                component: () => import('@/pages/model/business/list.vue'),
                                meta: {
                                    keepAlive: true,
                                    hideMenu: true,
                                    permission: 'model:business:list'
                                }
                            },
                            {
                                path: 'detail/:id',
                                name: 'model-business-detail',
                                component: () => import('@/pages/model/business/detail.vue'),
                                meta: {
                                    title: '查看模型',
                                    keepAlive: true,
                                    hideMenu: true,
                                    permission: 'model:business:detail'
                                }
                            }
                        ]
                    },
                    {
                        path: '/model/page',
                        name: 'model-page',
                        meta: {
                            title: '页面模型定义'
                        },
                        redirect: '/model/page/list',
                        children: [
                            {
                                path: 'list',
                                name: 'model-page-list',
                                component: () => import('@/pages/model/page/list.vue'),
                                meta: {
                                    keepAlive: true,
                                    hideMenu: true,
                                    permission: 'model:page:list'
                                }
                            }
                        ]
                    }
                ]
            },
            {
                path: '/IoT',
                name: 'IoT',
                meta: {
                    title: '物联网'
                },
                children: [
                    {
                        path: '/IoT/product',
                        name: 'IoT-product',
                        meta: {
                            title: '产品管理'
                        },
                        redirect: '/IoT/product/list',
                        children: [
                            {
                                path: '/IoT/product/list',
                                name: 'IoT-product-list',
                                component: () => import('@/pages/IoT/product/list.vue'),
                                meta: {
                                    keepAlive: true,
                                    hideMenu: true,
                                    permission: 'iot:product:list'
                                }
                            },
                            {
                                path: '/IoT/product/detail/:id',
                                name: 'IoT-product-detail',
                                component: () => import('@/pages/IoT/product/detail.vue'),
                                meta: {
                                    title: '查看产品',
                                    keepAlive: true,
                                    hideMenu: true,
                                    permission: 'iot:product:detail'
                                }
                            }
                        ]
                    },
                    {
                        path: '/IoT/device',
                        name: 'IoT-device',
                        meta: {
                            title: '设备管理'
                        },
                        redirect: '/IoT/device/list',
                        children: [
                            {
                                path: '/IoT/device/list',
                                name: 'IoT-device-list',
                                component: () => import('@/pages/IoT/device/list.vue'),
                                meta: {
                                    keepAlive: true,
                                    hideMenu: true,
                                    permission: 'iot:device:list'
                                }
                            },
                            {
                                path: '/IoT/device/detail/:id',
                                name: 'IoT-device-detail',
                                component: () => import('@/pages/IoT/device/detail.vue'),
                                meta: {
                                    title: '查看设备',
                                    keepAlive: true,
                                    hideMenu: true,
                                    permission: 'iot:device:detail'
                                }
                            }
                        ]
                    },
                    {
                        path: '/IoT/task',
                        name: 'IoT-task',
                        meta: {
                            title: '任务管理'
                        },
                        redirect: '/IoT/task/list',
                        children: [
                            {
                                path: '/IoT/task/list',
                                name: 'IoT-task-list',
                                component: () => import('@/pages/IoT/task/list.vue'),
                                meta: {
                                    title: '任务管理',
                                    keepAlive: true,
                                    hideMenu: true,
                                    permission: 'iot:task:list'
                                }
                            },
                            {
                                path: '/IoT/task/detail/:id',
                                name: 'IoT-task-detail',
                                component: () => import('@/pages/IoT/task/detail.vue'),
                                meta: {
                                    title: '查看任务',
                                    keepAlive: true,
                                    hideMenu: true,
                                    permission: 'iot:task:detail'
                                }
                            }
                        ]
                    },
                    {
                        path: '/IoT/protocol',
                        name: 'IoT-protocol',
                        meta: {
                            title: '协议管理'
                        },
                        redirect: '/IoT/protocol/list',
                        children: [
                            {
                                path: '/IoT/protocol/list',
                                name: 'IoT-protocol-list',
                                component: () => import('@/pages/IoT/protocol/list.vue'),
                                meta: {
                                    title: '协议管理',
                                    keepAlive: true,
                                    hideMenu: true,
                                    permission: 'iot:protocol:list'
                                }
                            },
                            {
                                path: '/IoT/protocol/detail/:id',
                                name: 'IoT-protocol-detail',
                                component: () => import('@/pages/IoT/protocol/detail.vue'),
                                meta: {
                                    title: '查看协议',
                                    keepAlive: true,
                                    hideMenu: true,
                                    permission: 'iot:protocol:detail'
                                }
                            }
                        ]
                    }
                ]
            },
            {
                path: '/message',
                name: 'message',
                meta: {
                    title: '消息集成'
                },
                children: [
                    {
                        path: '/message/product/list',
                        name: 'message-product-list',
                        component: () => import('@/pages/message/product/list.vue'),
                        meta: {
                            title: '产品集成设置',
                            keepAlive: true,
                            permission: 'message:product:list'
                        }
                    },
                    {
                        path: '/message/classify/list',
                        name: 'message-classify-list',
                        component: () => import('@/pages/message/classify/list.vue'),
                        meta: {
                            title: '消息类型',
                            keepAlive: true,
                            permission: 'message:classify:list'
                        }
                    },
                    {
                        path: '/message/integration',
                        name: 'message-integration',
                        meta: {
                            title: '消息集成'
                        },
                        redirect: '/message/integration/list',
                        children: [
                            {
                                path: '/message/integration/list',
                                name: 'message-integration-list',
                                component: () => import('@/pages/message/integration/list.vue'),
                                meta: {
                                    keepAlive: true,
                                    hideMenu: true,
                                    permission: 'message:integration:list'
                                }
                            },
                            {
                                path: '/message/integration/detail/:id',
                                name: 'message-integration-detail',
                                component: () => import('@/pages/message/integration/detail.vue'),
                                meta: {
                                    title: '查看消息',
                                    keepAlive: true,
                                    hideMenu: true,
                                    permission: 'message:integration:detail'
                                }
                            }
                        ]
                    }
                ]
            },
            {
                path: '/run',
                name: 'run',
                meta: {
                    title: '运维管理'
                },
                children: [
                    {
                        path: '/run/task',
                        name: 'run-task',
                        meta: {
                            title: '任务日志'
                        },
                        redirect: '/run/task/list',
                        children: [
                            {
                                path: '/run/task/list',
                                name: 'run-task-list',
                                component: () => import('@/pages/run/task/list.vue'),
                                meta: {
                                    keepAlive: true,
                                    hideMenu: true,
                                    permission: 'run:task:list'
                                }
                            },
                            {
                                path: '/run/task/history/:id/:no',
                                name: 'run-task-history',
                                component: () => import('@/pages/run/task/history.vue'),
                                meta: {
                                    title: '任务日志历史',
                                    keepAlive: true,
                                    hideMenu: true,
                                    permission: 'run:task:history'
                                }
                            }
                        ]
                    },
                    {
                        path: '/run/label/index',
                        name: 'run-label-index',
                        component: () => import('@/pages/run/label/index.vue'),
                        meta: {
                            title: '标签管理',
                            keepAlive: true,
                            permission: 'run:label:index'
                        }
                    },
                    {
                        path: '/run/spi/list',
                        name: 'run-spi-list',
                        component: () => import('@/pages/run/spi/list.vue'),
                        meta: {
                            title: 'Spi管理',
                            keepAlive: true,
                            permission: 'run:spi:list'
                        }
                    },
                    {
                        path: '/run/scriptManage',
                        name: 'run-script-list',
                        component: () => import('@/pages/run/scriptManage/index.vue'),
                        meta: {
                            title: '脚本管理',
                            keepAlive: true,
                            permission: 'run:scriptmanage:list'
                        }
                    },
                    {
                        path: '/run/networkComponent',
                        name: 'run-network-component-list',
                        component: () => import('@/pages/run/networkComponent/index.vue'),
                        meta: {
                            title: '网络组件',
                            keepAlive: true,
                            permission: 'run:networkcomponent:list'
                        }
                    }
                ]
            },
            {
                path: '/system',
                name: 'system',
                meta: {
                    title: '系统管理'
                },
                children: [
                    {
                        path: '/system/app',
                        name: 'system-app',
                        component: () => import('@/pages/system/app/index.vue'),
                        meta: {
                            title: '应用管理',
                            keepAlive: true,
                            permission: 'system:app:list'
                        }
                    },
                    {
                        path: '/system/user',
                        name: 'system-user',
                        redirect: '/system/user/index',
                        children: [
                            {
                                path: 'index',
                                name: 'system-user-index',
                                component: () => import('@/pages/system/user/index.vue'),
                                meta: {
                                    title: '用户管理',
                                    keepAlive: true,
                                    permission: 'system:user:list'
                                }
                            },
                            {
                                path: 'auth/role/:userId(\\d+)',
                                name: 'system-user-authRole',
                                component: () => import('@/pages/system/user/authRole.vue'),
                                meta: {
                                    title: '分配角色',
                                    hideMenu: true,
                                    keepAlive: true,
                                    permission: 'system:user:edit'
                                }
                            },
                            {
                                path: '/user/profile',
                                name: 'user-profile',
                                component: () => import('@/pages/system/user/profile/index.vue'),
                                meta: { title: '个人中心' }
                            }
                        ]
                    },
                    {
                        path: '/system/role',
                        name: 'system-role',
                        redirect: '/system/role/index',
                        children: [
                            {
                                path: 'index',
                                component: () => import('@/pages/system/role/index.vue'),
                                meta: {
                                    title: '角色管理',
                                    keepAlive: true,
                                    permission: 'system:role:list'
                                }
                            },
                            {
                                path: 'auth/user/:roleId(\\d+)',
                                name: 'system-role-authRole',
                                component: () => import('@/pages/system/role/authUser.vue'),
                                meta: {
                                    title: '分配用户',
                                    hideMenu: true,
                                    keepAlive: true,
                                    permission: 'system:role:edit'
                                }
                            }
                        ]
                    },
                    {
                        path: '/system/menu',
                        name: 'system-menu',
                        component: () => import('@/pages/system/menu/index.vue'),
                        meta: {
                            title: '菜单管理',
                            keepAlive: true,
                            permission: 'system:menu:list'
                        }
                    },
                    {
                        path: '/system/dept',
                        name: 'system-dept',
                        component: () => import('@/pages/system/dept/index.vue'),
                        meta: {
                            title: '组织管理',
                            keepAlive: true,
                            permission: 'system:dept:list'
                        }
                    },
                    {
                        path: '/system/post',
                        name: 'system-post',
                        component: () => import('@/pages/system/post/index.vue'),
                        meta: {
                            title: '岗位管理',
                            keepAlive: true,
                            permission: 'system:post:list'
                        }
                    },
                    {
                        path: '/system/dict',
                        name: 'system-dict',
                        redirect: '/system/dict/index',
                        children: [
                            {
                                path: 'index',
                                component: () => import('@/pages/system/dict/index.vue'),
                                meta: {
                                    title: '字典管理',
                                    keepAlive: true,
                                    permission: 'system:dict:list'
                                }
                            },
                            {
                                path: 'data/:dictId(\\d+)',
                                component: () => import('@/pages/system/dict/data.vue'),
                                meta: {
                                    title: '字典数据',
                                    hideMenu: true,
                                    keepAlive: true,
                                    permission: 'system:dict:data'
                                }
                            }
                        ]
                    },
                    {
                        path: '/system/config',
                        name: 'system-config',
                        component: () => import('@/pages/system/config/index.vue'),
                        meta: {
                            title: '参数设置',
                            keepAlive: true,
                            permission: 'system:config:list'
                        }
                    },
                    {
                        path: '/system/notice',
                        name: 'system-notice',
                        component: () => import('@/pages/system/notice/index.vue'),
                        meta: {
                            title: '通知公告',
                            keepAlive: true,
                            permission: 'system:notice:list'
                        }
                    },
                    {
                        path: '/system/log',
                        name: 'system-log',
                        meta: {
                            title: '日志管理'
                        },
                        children: [
                            {
                                path: '/system/log/operlog',
                                name: 'system-log-operlog',
                                component: () => import('@/pages/system/log/operlog/index.vue'),
                                meta: {
                                    title: '操作日志',
                                    keepAlive: true,
                                    permission: 'monitor:operlog:list'
                                }
                            },
                            {
                                path: '/system/log/logininfor',
                                name: 'system-log-logininfor',
                                component: () => import('@/pages/system/log/loginlog/index.vue'),
                                meta: {
                                    title: '登录日志',
                                    keepAlive: true,
                                    permission: 'monitor:logininfor:list'
                                }
                            }
                        ]
                    },
                    {
                        path: '/system/oss',
                        name: 'system-oss',
                        redirect: '/system/oss/index',
                        children: [
                            {
                                path: 'index',
                                component: () => import('@/pages/system/oss/index.vue'),
                                meta: {
                                    title: '文件管理',
                                    keepAlive: true,
                                    permission: 'system:oss:list'
                                }
                            },
                            {
                                path: 'config',
                                component: () => import('@/pages/system/oss/config.vue'),
                                meta: {
                                    title: '配置管理',
                                    hideMenu: true,
                                    keepAlive: true,
                                    permission: 'system:ossConfig:list'
                                }
                            }
                        ]
                    },
                    {
                        path: '/system/client',
                        name: 'system-client',
                        component: () => import('@/pages/system/client/index.vue'),
                        meta: {
                            title: '客户端管理',
                            keepAlive: true,
                            permission: 'system:client:list'
                        }
                    },
                    {
                        path: '/system/tenant',
                        name: 'system-tenant',
                        component: () => import('@/pages/system/tenant/index.vue'),
                        meta: {
                            title: '租户管理',
                            keepAlive: true,
                            permission: 'system:tenant:list'
                        }
                    }
                ]
            },
            {
                path: '/page/:code',
                name: 'custom-page',
                component: () => import('@/pages/model/page/preview.vue'),
                meta: {
                    title: '查看页面',
                    keepAlive: true,
                    permission: 'page:dashboard:index'
                }
            },
            {
                path: '/:pathMatch(.*)*',
                name: 'notFound',
                component: () => import('@/pages/404.vue'),
                meta: {
                    title: '404',
                    hideMenu: true
                }
            }
        ]
    },
    {
        path: '/model/page/detail/:code',
        name: 'model-page-detail',
        component: () => import('@/pages/model/page/design.vue'),
        meta: {
            title: '页面设计',
            hideMenu: true,
            permission: 'model:page:design'
        }
    },
    {
        path: '/login',
        name: 'login',
        component: () => import('@/pages/login.vue')
    },
    ...(import.meta.env.DEV ? devTestRoutes : [])
];
